<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="12" :sm="16">
            <a-form-item label="创建日期">
              <j-date placeholder="请选择开始日期" class="query-group-cust" v-model="queryParam.createTime_begin"></j-date>
              <span class="query-group-split-cust"></span>
              <j-date placeholder="请选择结束日期" class="query-group-cust" v-model="queryParam.createTime_end"></j-date>
            </a-form-item>
          </a-col>
        <a-col :md="6" :sm="8">
          <a-form-item label="经办人">
            <a-input placeholder="请输入经办人" v-model="queryParam.query01"></a-input>
          </a-form-item>
        </a-col>
        <template v-if="toggleSearchStatus">
          <a-col :md="6" :sm="8">
            <a-form-item label="企业名称">
              <a-input placeholder="请输入企业名称" v-model="queryParam.query08"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="统一社会代码">
              <a-input placeholder="请输入统一社会代码" v-model="queryParam.query09"></a-input>
            </a-form-item>
          </a-col>
           <!-- <a-col :md="6" :sm="8">
              <a-form-item label="备用9">
                <a-input placeholder="请输入备用9" v-model="queryParam.query18"></a-input>
              </a-form-item>
            </a-col> -->
          </template>
          <a-col :md="6" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('xm_main_01')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :scroll="{ x: 4000 }"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type:'radio'}"
        :customRow="clickThenSelect"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="图片不存在" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <!-- <a @click="tongyi(record.id)">同意</a>
          <a @click="jujue(record.id)">拒绝</a> -->
          
          <!-- <a-popconfirm title="确定受理吗?" @confirm="() => tongyi(record.id)">
            <a>受理</a>
          </a-popconfirm>
          <a-divider type="vertical" />
          <a-popconfirm title="确定退回已初审吗?" @confirm="() => tuihui(record.id)">
            <a>退回</a>
          </a-popconfirm> -->

         <a @click="handleEdit(record)">受理</a>
          
        </span>

      </a-table>
    </div>

    <a-tabs defaultActiveKey="1">
      <a-tab-pane tab="提报信息" key="1" >
        <xm-item-02-list :mainId="selectedMainId" />
      </a-tab-pane>
      <a-tab-pane tab="审核意见" key="2" forceRender>
        <xm-item-01-list :mainId="selectedMainId" />
      </a-tab-pane>
    </a-tabs>

    <xmMain03-modal ref="modalForm" @ok="modalFormOk"></xmMain03-modal>
  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import XmMain03Modal from './modules/XmMain03Modal'
  import { getAction } from '@/api/manage'
  import XmItem02List from './XmItem02List'
  import XmItem01List from './XmItem01List'
  import JDate from '@/components/jeecg/JDate.vue'

  export default {
    name: "XmMain03List",
    mixins:[JeecgListMixin],
    components: {
      JDate,
      XmItem02List,
      XmItem01List,
      XmMain03Modal
    },
    data () {
      return {
        queryParam:{
          query18:''
        },
        description: 'xm_main_01管理页面',
        // 表头
        columns: [
          
         {
           title: '操作',
           dataIndex: 'action',
           align:"center",
           scopedSlots: { customRender: 'action' },
         },
         // {
         //   title:'创建人',
         //   align:"center",
         //   dataIndex: 'createBy'
         // }
         // ,
         
         {
           title:'创建日期',
           align:"center",
           dataIndex: 'createTime',
           customRender:function (text) {
             return !text?"":(text.length>10?text.substr(0,10):text)
           }
         },
         // {
         //   title:'更新人',
         //   align:"center",
         //   dataIndex: 'updateBy'
         // },
         // {
         //   title:'更新日期',
         //   align:"center",
         //   dataIndex: 'updateTime',
         //   customRender:function (text) {
         //     return !text?"":(text.length>10?text.substr(0,10):text)
         //   }
         // },
         // {
         //   title:'所属部门',
         //   align:"center",
         //   dataIndex: 'sysOrgCode'
         // },
         {
           title:'经办人',
           align:"center",
           dataIndex: 'query01'
         },
         {
           title:'邮箱',
           align:"center",
           dataIndex: 'query02'
         },
         {
           title:'经办人电话',
           align:"center",
           dataIndex: 'query03'
         },
         // {
         //   title:'产品标签',
         //   align:"center",
         //   dataIndex: 'query04'
         // },
         // {
         //   title:'产品介绍',
         //   align:"center",
         //   dataIndex: 'query05'
         // },
         // {
         //   title:'适用人群',
         //   align:"center",
         //   dataIndex: 'query06'
         // },
         // {
         //   title:'贷款类型',
         //   align:"center",
         //   dataIndex: 'query07'
         // },
         {
           title:'企业名称',
           align:"center",
           dataIndex: 'query08'
         },
         {
           title:'统一信用代码',
           align:"center",
           dataIndex: 'query09'
         },
         {
           title:'街道',
           align:"center",
           dataIndex: 'query10'
         },
         {
           title:'成立日期',
           align:"center",
           dataIndex: 'query11'
         },
         {
           title:'行业',
           align:"center",
           dataIndex: 'query12'
         },
         {
           title:'营业收入',
           align:"center",
           dataIndex: 'query13'
         },
         {
           title:'人数',
           align:"center",
           dataIndex: 'query14'
         },
         {
           title:'主营业务收入',
           align:"center",
           dataIndex: 'query15'
         },
         {
           title:'备用7',
           align:"center",
           dataIndex: 'query16'
         },
         {
           title:'备用8',
           align:"center",
           dataIndex: 'query17'
         },
         {
           title:'状态',
           align:"center",
           dataIndex: 'query18'
         },
          // ,
          // {
          //   title:'备用10',
          //   align:"center",
          //   dataIndex: 'query19'
          // },
          // {
          //   title:'备用11',
          //   align:"center",
          //   dataIndex: 'query20'
          // },
          // {
          //   title:'备用12',
          //   align:"center",
          //   dataIndex: 'query21'
          // },
          {
            title:'授权委托书',
            align:"center",
            dataIndex: 'query22'
          },
          {
            title:'营业执照副本',
            align:"center",
            dataIndex: 'query23'
          },
          {
            title:'2019年度资产负债表',
            align:"center",
            dataIndex: 'query24'
          },
          {
            title:'2019年度资产损益表',
            align:"center",
            dataIndex: 'query25'
          },
          // {
          //   title:'备用17',
          //   align:"center",
          //   dataIndex: 'query26'
          // },
          // {
          //   title:'备用18',
          //   align:"center",
          //   dataIndex: 'query27'
          // },
          // {
          //   title:'备用19',
          //   align:"center",
          //   dataIndex: 'query28'
          // },
          // {
          //   title:'备用20',
          //   align:"center",
          //   dataIndex: 'query29'
          // },
          // {
          //   title:'备用21',
          //   align:"center",
          //   dataIndex: 'query30'
          // },
          // {
          //   title:'备用22',
          //   align:"center",
          //   dataIndex: 'query31'
          // },
          // {
          //   title:'备用23',
          //   align:"center",
          //   dataIndex: 'query32'
          // },
          // {
          //   title:'备用24',
          //   align:"center",
          //   dataIndex: 'query33'
          // },
          // {
          //   title:'备用25',
          //   align:"center",
          //   dataIndex: 'query34'
          // },
          // {
          //   title:'备用26',
          //   align:"center",
          //   dataIndex: 'query35'
          // },
          // {
          //   title:'备用27',
          //   align:"center",
          //   dataIndex: 'query36'
          // },
          // {
          //   title:'备用28',
          //   align:"center",
          //   dataIndex: 'query37'
          // },
          // {
          //   title:'备用29',
          //   align:"center",
          //   dataIndex: 'query38'
          // },
          // {
          //   title:'备用30',
          //   align:"center",
          //   dataIndex: 'query39'
          // },
          // {
          //   title:'RID',
          //   align:"center",
          //   dataIndex: 'query40'
          // }
        ],
        url: {
          list: "/xm/xmMain01/listysj",
          changeById: "/xm/xmMain01/changeById",
          delete: "/xm/xmMain01/delete",
          deleteBatch: "/xm/xmMain01/deleteBatch",
          exportXlsUrl: "/xm/xmMain01/exportXls",
          importExcelUrl: "xm/xmMain01/importExcel",
        },
        dictOptions:{
        },
        /* 分页参数 */
        ipagination:{
          current: 1,
          pageSize: 5,
          pageSizeOptions: ['5', '10', '50'],
          showTotal: (total, range) => {
            return range[0] + "-" + range[1] + " 共" + total + "条"
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0
        },
        selectedMainId:''

      }
    },
    mounted() {
      
      this.queryParam.query18 = '已收件'
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      tuihui:function(e){
        let url = this.url.changeById + '?status=已初审&id=' + e
        getAction(url, e).then((res) => {
          this.loadData();
        })
      },
      tongyi:function(e){
        let url = this.url.changeById + '?status=已受理&id=' + e
        getAction(url, e).then((res) => {
          this.loadData();
        })
      },
      
      initDictConfig(){
      },
      clickThenSelect(record) {
        return {
          on: {
            click: () => {
              this.onSelectChange(record.id.split(","), [record]);
            }
          }
        }
      },
      onClearSelected() {
        this.selectedRowKeys = [];
        this.selectionRows = [];
        this.selectedMainId=''
      },
      onSelectChange(selectedRowKeys, selectionRows) {
        this.selectedMainId=selectedRowKeys[0]
        this.selectedRowKeys = selectedRowKeys;
        this.selectionRows = selectionRows;
      },
      loadData(arg) {
        if(!this.url.list){
          this.$message.error("请设置url.list属性!")
          return
        }
        //加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {
          this.ipagination.current = 1;
        }
        this.onClearSelected()
        var params = this.getQueryParams();//查询条件
        this.loading = true;
        getAction(this.url.list, params).then((res) => {
          if (res.success) {
            this.dataSource = res.result.records;
            this.ipagination.total = res.result.total;
          }
          if(res.code===510){
            this.$message.warning(res.message)
          }
          this.loading = false;
        })
      }

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>